package Pantallas;
import javax.swing.JButton;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JSpinner;
import javax.swing.JTextField;
import javax.swing.SpinnerListModel;
import javax.swing.SwingUtilities;
import javax.swing.border.BevelBorder;
import Clases.*;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;

/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class BusEstudiante extends javax.swing.JDialog {
	private JButton jButton3;
	private JButton jButton1;
	private JLabel jLabel5;
	private JPanel jPanel1;
	private JButton jButton2;
	private JLabel jLabel14;
	private JLabel jLabel13;
	private JLabel jLabel12;
	private JLabel jLabel11;
	private JLabel jLabel10;
	private JLabel jLabel9;
	private JLabel jLabel8;
	private JLabel jLabel1;
	private JTextField jTextField1;
	private JLabel jLabel2;
	private JLabel jLabel3;
	private JLabel jLabel4;
	private JLabel jLabel6;
	private JLabel jLabel7;
	Seccion sec;

	/**
	* Auto-generated main method to display this JDialog
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				JFrame frame = new JFrame();
				BusEstudiante inst = new BusEstudiante(frame);
				inst.setVisible(true);
			}
		});
	}
	
	public BusEstudiante(JFrame frame) {
		super(frame);
		initGUI();
	}
	public BusEstudiante(JFrame frame,Seccion sec) {
		super(frame);
		initGUI();
		this.sec=sec;
	}
	
	private void initGUI() {
		try {
			{
			getContentPane().setLayout(null);
				{
					jButton3 = new JButton();
					getContentPane().add(jButton3);
					jButton3.setText("Volver");
					jButton3.setBounds(206, 265, 104, 22);
					jButton3.setIcon(new ImageIcon(getClass().getClassLoader().getResource("imagenes/icono-flecha-izq.gif.png")));
					jButton3.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent evt) {
							System.out.println("jButton3.actionPerformed, event="+evt);
							//TODO add your code for jButton3.actionPerformed
							dispose();
						}
					});
				}
				{
					jButton1 = new JButton();
					getContentPane().add(jButton1);
					jButton1.setText("");
					jButton1.setBounds(272, 68, 39, 22);
					jButton1.setFont(new java.awt.Font("Dialog",0,10));
					jButton1.setIcon(new ImageIcon(getClass().getClassLoader().getResource("imagenes/buscar.gif")));
					jButton1.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent evt) {
							System.out.println("jButton1.actionPerformed, event="+evt);
							//TODO add your code for jButton1.actionPerformed
							Estudiante e =sec.BuscarEstudiante(jTextField1.getText());
							if (e.getCedula().equals(""))
								JOptionPane.showMessageDialog(null, "Estudiante no encontrado");
							else
							{
								jLabel8.setText(e.getNombre());
								jLabel9.setText(e.getApellido());
								jLabel10.setText(""+e.getNota1());
								jLabel11.setText(""+e.getNota2());
								jLabel12.setText(""+e.getNota3());
								jLabel13.setText(""+e.getNotafinal());
							}

						}
					});
				}
				{
					jLabel7 = new JLabel();
					getContentPane().add(jLabel7);
					jLabel7.setText("Nota Final:");
					jLabel7.setBounds(42, 214, 67, 15);
					jLabel7.setFont(new java.awt.Font("Dialog",0,10));
				}
				{
					jLabel6 = new JLabel();
					getContentPane().add(jLabel6);
					jLabel6.setText("Nota 3:");
					jLabel6.setBounds(272, 165, 46, 15);
					jLabel6.setFont(new java.awt.Font("Dialog",0,10));
				}
				{
					jLabel5 = new JLabel();
					getContentPane().add(jLabel5);
					jLabel5.setText("Nota 2:");
					jLabel5.setBounds(160, 165, 46, 15);
					jLabel5.setFont(new java.awt.Font("Dialog",0,10));
				}
				{
					jLabel4 = new JLabel();
					getContentPane().add(jLabel4);
					jLabel4.setText("Nota 1:");
					jLabel4.setBounds(42, 165, 46, 15);
					jLabel4.setFont(new java.awt.Font("Dialog",0,10));
				}
				{
					jLabel3 = new JLabel();
					getContentPane().add(jLabel3);
					jLabel3.setText("Apellido");
					jLabel3.setBounds(41, 135, 49, 15);
					jLabel3.setFont(new java.awt.Font("Dialog",0,10));
				}
				{
					jLabel2 = new JLabel();
					getContentPane().add(jLabel2);
					jLabel2.setText("Nombre:");
					jLabel2.setBounds(41, 104, 53, 15);
					jLabel2.setFont(new java.awt.Font("Dialog",0,10));
				}
				{
					jTextField1 = new JTextField();
					getContentPane().add(jTextField1);
					jTextField1.setBounds(116, 68, 138, 22);
					jTextField1.addKeyListener(new KeyAdapter() {
						public void keyReleased(KeyEvent evt) {
							System.out.println("jTextField1.keyReleased, event="+evt);
							Validador val = new Validador();
							if (!val.validarNumero(evt))
							{
								jTextField1.setText("");
								JOptionPane.showMessageDialog(null, "Cedula Invalida");
							}
							//TODO add your code for jTextField1.keyReleased
						}
					});
				}
				{
					jLabel1 = new JLabel();
					getContentPane().add(jLabel1);
					jLabel1.setText("Cedula:");
					jLabel1.setBounds(41, 70, 75, 16);
					jLabel1.setFont(new java.awt.Font("Dialog",0,10));
				}
				{
					jLabel8 = new JLabel();
					getContentPane().add(jLabel8);
					jLabel8.setText("    ");
					jLabel8.setBounds(116, 101, 138, 20);
					jLabel8.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
				}
				{
					jLabel9 = new JLabel();
					getContentPane().add(jLabel9);
					jLabel9.setText("    ");
					jLabel9.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
					jLabel9.setBounds(116, 133, 138, 19);
				}
				{
					jLabel10 = new JLabel();
					getContentPane().add(jLabel10);
					jLabel10.setText("    ");
					jLabel10.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
					jLabel10.setBounds(42, 181, 74, 20);
				}
				{
					jLabel11 = new JLabel();
					getContentPane().add(jLabel11);
					jLabel11.setText("    ");
					jLabel11.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
					jLabel11.setBounds(160, 181, 69, 20);
				}
				{
					jLabel12 = new JLabel();
					getContentPane().add(jLabel12);
					jLabel12.setText("    ");
					jLabel12.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
					jLabel12.setBounds(272, 181, 70, 20);
				}
				{
					jLabel13 = new JLabel();
					getContentPane().add(jLabel13);
					jLabel13.setText("    ");
					jLabel13.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
					jLabel13.setBounds(160, 214, 69, 20);
				}
				{
					jLabel14 = new JLabel();
					getContentPane().add(jLabel14);
					jLabel14.setText("Buscar Estudiante");
					jLabel14.setBounds(100, 21, 206, 25);
					jLabel14.setFont(new java.awt.Font("Dialog",1,18));
				}
				{
					jButton2 = new JButton();
					getContentPane().add(jButton2);
					jButton2.setText("Limpiar");
					jButton2.setBounds(88, 265, 107, 22);
					jButton2.setIcon(new ImageIcon(getClass().getClassLoader().getResource("imagenes/page.gif")));
					jButton2.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent evt) {
							System.out.println("jButton2.actionPerformed, event="+evt);
							//TODO add your code for jButton2.actionPerformed
							jTextField1.setText(null);
							jLabel8.setText(null);
							jLabel9.setText(null);
							jLabel10.setText(null);
							jLabel11.setText(null);
							jLabel12.setText(null);
							jLabel13.setText(null);
						}
						
					});
				}
				{
					jPanel1 = new JPanel();
					getContentPane().add(jPanel1);
					jPanel1.setBounds(14, 52, 362, 195);
					jPanel1.setBorder(BorderFactory.createTitledBorder(""));
				}
			}
			this.setSize(403, 334);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
